package com.rainbow.gray.plugin.framework.starter.gateway.configuration;

import org.springframework.boot.autoconfigure.AutoConfigureBefore;
import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean;
import org.springframework.cloud.netflix.ribbon.RibbonClientConfiguration;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

import com.rainbow.gray.framework.adapter.strategy.DefaultDiscoveryEnabledAdapter;
import com.rainbow.gray.framework.adapter.strategy.DiscoveryEnabledAdapter;
import com.rainbow.gray.plugin.framework.starter.gateway.filter.DefaultGatewayStrategyClearFilter;
import com.rainbow.gray.plugin.framework.starter.gateway.filter.DefaultGatewayStrategyContextFilter;
import com.rainbow.gray.plugin.framework.starter.gateway.filter.GatewayStrategyClearFilter;
import com.rainbow.gray.plugin.framework.starter.gateway.filter.GatewayStrategyContextFilter;

@Configuration
@AutoConfigureBefore(RibbonClientConfiguration.class)
public class GatewayStrategyAutoConfiguration {
    @Bean
    @ConditionalOnMissingBean
    public GatewayStrategyContextFilter gatewayStrategyRouteFilter() {
        return new DefaultGatewayStrategyContextFilter();
    }

    @Bean
    @ConditionalOnMissingBean
    public GatewayStrategyClearFilter gatewayStrategyClearFilter() {
        return new DefaultGatewayStrategyClearFilter();
    }

    @Bean
    @ConditionalOnMissingBean
    public DiscoveryEnabledAdapter discoveryEnabledAdapter() {
        return new DefaultDiscoveryEnabledAdapter();
    }
}